﻿//using System;
//using System.IO;
//using System.Security.Cryptography;
//using System.Text;
//using System.Web.Security;

//namespace SharpCommon.Utility
//{
//    public class DESEncryptHelper
//    {
//        public static string Decrypt(string text)
//        {
//            return Decrypt(text, "MATICSOFT");
//        }

//        public static string Decrypt(string text, string key)
//        {
//            DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
//            int num = text.Length / 2;
//            byte[] buffer = new byte[num];
//            for (int i = 0; i < num; i++)
//            {
//                int num3 = Convert.ToInt32(text.Substring(i * 2, 2), 0x10);
//                buffer[i] = (byte)num3;
//            }
//            provider.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(key, "md5").Substring(0, 8));
//            provider.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(key, "md5").Substring(0, 8));
//            MemoryStream stream = new MemoryStream();
//            CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(), CryptoStreamMode.Write);
//            stream2.Write(buffer, 0, buffer.Length);
//            stream2.FlushFinalBlock();
//            return Encoding.Default.GetString(stream.ToArray());
//        }

//        public static string Encrypt(string text)
//        {
//            return Encrypt(text, "MATICSOFT");
//        }

//        public static string Encrypt(string text, string key)
//        {
//            DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
//            byte[] bytes = Encoding.Default.GetBytes(text);
//            provider.Key = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(key, "md5").Substring(0, 8));
//            provider.IV = Encoding.ASCII.GetBytes(FormsAuthentication.HashPasswordForStoringInConfigFile(key, "md5").Substring(0, 8));
//            MemoryStream stream = new MemoryStream();
//            CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(), CryptoStreamMode.Write);
//            stream2.Write(bytes, 0, bytes.Length);
//            stream2.FlushFinalBlock();
//            StringBuilder builder = new StringBuilder();
//            foreach (byte num in stream.ToArray())
//            {
//                builder.AppendFormat("{0:X2}", num);
//            }
//            return builder.ToString();
//        }
//    }
//}
